package com.example.weibo_suhuanzhen.adapters;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.weibo_suhuanzhen.fragments.HomeFragment;
import com.example.weibo_suhuanzhen.fragments.LoggedInFragment;

public class CollectionPagerAdapter extends FragmentPagerAdapter {
    private HomeFragment homeFragment;
    private LoggedInFragment myFragment;

    public CollectionPagerAdapter(FragmentManager fm) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.homeFragment = new HomeFragment();
        this.myFragment = new LoggedInFragment();
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            return homeFragment;
        } else {
            return myFragment;
        }
    }

    @Override
    public int getCount() {
        return 2;
    }

    @Override
    public int getItemPosition(@NonNull Object object) {
        return POSITION_NONE;
    }

    public HomeFragment getHomeFragment() {
        return homeFragment;
    }

    public LoggedInFragment getMyFragment() {
        return myFragment;
    }
}
